package com.party.core.service.school.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.school.ScTeacherReadDao;
import com.party.core.dao.write.school.ScTeacherWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.school.ScTeacher;
import com.party.core.service.school.IScTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
public class ScTeacherService implements IScTeacherService {

    @Autowired
    private ScTeacherReadDao teacherReadDao;

    @Autowired
    private ScTeacherWriteDao teacherWriteDao;

    @Override
    public String insert(ScTeacher scTeacher) {
        BaseModel.preInsert(scTeacher);
        if (teacherWriteDao.insert(scTeacher)) {
            return scTeacher.getId();
        }
        return null;
    }

    @Override
    public boolean update(ScTeacher scTeacher) {
        scTeacher.setUpdateDate(new Date());
        return teacherWriteDao.update(scTeacher);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return teacherWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ScTeacher get(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return null;
        }
        return teacherReadDao.get(id);
    }

    @Override
    public List<ScTeacher> listPage(ScTeacher scTeacher, Page page) {
        return teacherReadDao.listPage(scTeacher, page);
    }

    @Override
    public List<ScTeacher> list(ScTeacher scTeacher) {
        return teacherReadDao.listPage(scTeacher, null);
    }

    @Override
    public List<ScTeacher> batchList(Set<String> ids, ScTeacher scTeacher, Page page) {
        return null;
    }

    @Override
    public List<ScTeacher> webListPage(ScTeacher teacher, Map<String, Object> params, Page page) {
        return teacherReadDao.webListPage(teacher, params, page);
    }
}
